import React from "react"
import ReactDOM from "react-dom"
import './index.less'
import AppWidget from "./AppWidget";
import Widget, { getAttribute, setAttribute } from '../common/Widget';
import Print from './widget/print';
import Markdown from "./apps/markdown";

// ant design
// import 'antd/dist/antd.css';

// babel
import '../../lib/babel.min.js';

// github markdown
// https://github.com/primer/github-syntax-light
// 此外引入主题模板,例如 import '../../lib/theme/github-markdown.css';
// 但是由于webpack的限制，无法动态地引入，因此由用户在页面中引入CSS文件。

// katex
import '../../lib/katex/katex.min.css';

import { H1, H2, H3, H4, H5, H6 } from "./apps/markdown/header";
import { Code, Del, Em, P, Strong, U } from "./apps/markdown/font";
import Hr from './apps/markdown/hr';
import { Cite, Ref } from "./apps/markdown/cite";
import { Li, Ol, Ul } from "./apps/markdown/list";
import { Table, Tbody, Td, Th, Thead, Tr } from "./apps/markdown/table";
import { A, Img } from "./apps/markdown/link";
import { CodeBlock, MathBlock, M } from "./apps/markdown/block";
import PowerPoint from "./apps/powerpoint";
import Frame from "./apps/powerpoint/frame";
import Parallel from "./apps/powerpoint/parallel";
import Component, { componentClass } from "../common/Component";
 
 // export names
let win = (window as any);
win.React = React;
win.Component = Component;
win.componentClass = componentClass;
win.Context = {
    getAttribute,
    setAttribute
}

// export components
const widgets:Widget =  {
    Print,
    Markdown,
    PowerPoint
};
win.Widget = widgets;
win.H1 = H1;
win.H2 = H2;
win.H3 = H3;
win.H4 = H4;
win.H5 = H5;
win.H6 = H6;
win.Em = Em;
win.P = P;
win.Strong = Strong;
win.Del = Del;
win.U = U;
win.Code =  Code
win.Hr = Hr;
win.Ref = Ref;
win.Ul = Ul;
win.Ol = Ol;
win.Li = Li;
win.Cite = Cite;
win.Table = Table;
win.Thead = Thead;
win.Tbody = Tbody;
win.Tr = Tr;
win.Th = Th;
win.Td = Td;
win.A = A;
win.Img = Img;
win.CodeBlock = CodeBlock;
win.MathBlock = MathBlock;
win.M = M;
win.Frame = Frame;
win.Parallel = Parallel;

// 绑定加载整件
win.onload = ()=>{
    ReactDOM.render( 
        // React.createElement(AppWidget),
        win.content ? win.content : <AppWidget/>,
        //document.getElementById("app")
        document.body
    )
}







